#!/bin/sh

mx_mapper_state_dir="/var/run/mx_mapper"
fma_run="/var/run/fms"

prefix=@mx_prefix@  #Note this is replaced by make install, not configure!
output=/dev/null

# Stop any mappers that happen to be left
for pid_file in `ls "${mx_mapper_state_dir}"/pid.* 2>/dev/null`
do
    # Read the stored PID.
    pid=`cat "${pid_file}"` || return $?
    # Kill the mapper.
    kill "${pid}" 2>/dev/null
    rm -f "${pid_file}"
done

# stop any FMAs
for pid_file in ${fma_run}/fma*pid; do
 if [ -r "${pid_file}" ]
 then
    # Read the stored PID.
    pid=`cat "${pid_file}"` || return $?

    # Kill the FMA
    kill "${pid}" 2>/dev/null
    rm -f "${pid_file}"
 fi
done

sleep 3
exit 0
